package com.qf.mxapp.util;
/*
* 文件上传工具
*
* */



import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

public class UpUtils {
    public static final String BASE_PATH = "src/main/resources/static/";

    public  static String upFile(MultipartFile file,String path) throws IOException {
        if(file.isEmpty()){
            return null;
        }

        String rsePath = new File(BASE_PATH).getAbsolutePath()+"/"+path +"/"+file.getOriginalFilename();
        File file1 = new File(rsePath);
        if(!file1.getParentFile().exists()){
            file1.getParentFile().mkdirs();
        }

        file.transferTo(file1);
        return "http://localhost:8080/"+ path + "/" + file.getOriginalFilename();

    }
}
